package com.gqb.dongtaiguihua;

import java.util.Scanner;

public class MaxSonXulie {
	public static void main(String[] args) {
		Scanner scanner=new Scanner(System.in);
		while (scanner.hasNext()) {
			int count=scanner.nextInt();
			int[] nums=new int[count];
			for (int i = 0; i < nums.length; i++) {
				nums[i]=scanner.nextInt();
			}
			int add=0;
			int startIndex=0;
			int sum=0;
			int max=-1000000;
			int start=0;
			int end=0;
			for (int i = 0; i < nums.length; i++) {
				sum=0;
				for (int j = i; j < nums.length; j++) {
					sum+=nums[j];
					if(sum>max){
						max=sum;
						start=i;
						end=j;
					}
				}
			}
			System.out.println(max);
			System.out.println(start+" "+end);
		}
	}
}
